<template>
  <div >
     <draggable v-model="tags" :move="getdata" @update="datadragEnd">
        <transition-group>
            <div class="move" v-for="element in tags" :key="element.id">
                {{element.name}}
            </div>
        </transition-group>
</draggable>
  </div>
</template>
 
<script>
import draggable from 'vuedraggable'
export default {
  components: {
  　　draggable
  },
  data () {
    return {
      tags:[
        {name:'1',id:'1'},
        {name:'2',id:'2'},
        {name:'3',id:'3'},
        {name:'4',id:'4'},
        {name:'5',id:'5'},
      ]
    }
  },
  methods: {
    getdata (evt) {
        console.log(evt.draggedContext.element.id)
      },
      datadragEnd (evt) {
        console.log('拖动前的索引 :' + evt.oldIndex)
        console.log('拖动后的索引 :' + evt.newIndex)
        console.log(this.tags)
      }
    }
}
</script>
 
<style lang="scss">
.move{
  margin: 10px auto;
}
</style>
